package com.study.demo_controlleradvice.controlleradvice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @ClassName: MyError
 * @Description:
 * @author: WS
 * @date 2020/12/11
 * @Version: 1.0
 **/
@ControllerAdvice
public class MyErrorController {
    @ExceptionHandler(Exception.class)
    public ModelAndView myException(Exception e){
        ModelAndView myerror = new ModelAndView("myerror");
        myerror.addObject("error",e.getMessage());
        return myerror;
    }
}
